package com.yydm.serviceedu.controller;

import com.yydm.commonutils.R;
import com.yydm.serviceedu.service.OssService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Classname OssController
 * @Description TODO
 * @Version 1.0.0
 * @Date 2022/6/23 18:17
 * @Created by liu25
 */

@RestController
@RequestMapping("/fileoss")
//@CrossOrigin
public class OssController {

    @Autowired
    private OssService ossService;

    //    文件上传
    @ApiOperation(value = "文件上传")
    @PostMapping("/upload")
    public R upload(MultipartFile file) {
        String url = ossService.upload(file);
        return R.ok().message("上传成功").data("url", url);
    }

}
